#include <cstdio>
using namespace std;

const int N = 1000001;
int n, m, a[60];
bool vis[N];

int main() {

#ifndef ONLINE_JUDGE
#ifdef DEBUG
	freopen("testdata.in", "r", stdin);
	freopen("testdata.out", "w", stdout);
#endif
#ifndef DEBUG
	freopen("running.in", "r", stdin);
	freopen("running.out", "w", stdout);
#endif
#endif
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++i) {
		scanf("%d", &a[i]);
	}
	for (int i = 1; i <= m; ++i) {
		for (int j = 0; j <= 10000; ++j) {
			vis[(j * a[i]) % n] = true;
		}
	}
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if (!vis[i]) ans++;
	}
	printf("%d", ans);
	return 0;
}